import 'package:flutter/cupertino.dart';
import 'package:website.core/core/presentation/localization/translation.dart';
import 'package:website.core/core/presentation/theme/theme.dart';
import 'package:website.core/core/presentation/widgets/app_button.dart';
import 'package:website.core/core/presentation/widgets/header_action_dialog.dart';

class HeaderAuthorizationButton extends StatelessWidget {
  const HeaderAuthorizationButton({
    required this.iconSize,
    required this.onSigningInTilePressed,
    required this.onSigningUpTilePressed,
    Key? key,
  }) : super(key: key);

  final double iconSize;
  final VoidCallback onSigningInTilePressed;
  final VoidCallback onSigningUpTilePressed;

  void _onPressed({
    required BuildContext context,
  }) {
    showHeaderActionDialog(
      context: context,
      arrowDyOffset: -8.0,
      items: [
        HeaderActionDialogItem(
          icon: Icon(
            CupertinoIcons.person_crop_circle_badge_checkmark,
            color: CoreTheme.of(context).headerActionDialogTileIconColor,
            size: 24,
          ),
          title: CoreTranslation.of(context).headerUserActionDialogSigningInActionTileTitle,
          onPressed: onSigningInTilePressed,
        ),
        HeaderActionDialogItem(
          icon: Icon(
            CupertinoIcons.person_crop_circle_badge_plus,
            color: CoreTheme.of(context).headerActionDialogTileIconColor,
            size: 24,
          ),
          title: CoreTranslation.of(context).headerUserActionDialogSigningUpActionTileTitle,
          onPressed: onSigningUpTilePressed,
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return AppButton(
      pressedOpacity: 0.6,
      onPressed: () {
        _onPressed(
          context: context,
        );
      },
      child: Padding(
        padding: const EdgeInsets.all(10.0),
        child: Icon(
          CupertinoIcons.square_arrow_right,
          color: CoreTheme.of(context).headerAuthorizationButtonIconColor,
          size: iconSize,
        ),
      ),
    );
  }
}
